﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="ManejoInformaticos.aspx.cs" Inherits="TCU.Manejo_Informaticos" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">

    <script>
        //Permite que se puede seleccionar celdas, sin dejar de seleccionar las otras.
        var multiSelect = {};
        function init() {
            var s = document.getElementsByTagName('select');
            for (var i = 0; i < s.length; i++) {
                if (s[i].multiple) {
                    var n = s[i].name;
                    multiSelect[n] = [];
                    for (var j = 0; j < s[i].options.length; j++) {
                        multiSelect[n][j] = s[i].options[j].selected;
                    }
                    s[i].onclick = changeMultiSelect;
                }
            }
        }
        function changeMultiSelect() {
            var n = this.name;
            for (var i = 0; i < this.options.length; i++) {
                if (this.options[i].selected) {
                    multiSelect[n][i] = !multiSelect[n][i];
                }
                this.options[i].selected = multiSelect[n][i];
            }
        }
        window.onload = init;
    </script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:Label ID="notificacion" runat="server" ForeColor="Red" ></asp:Label>
    <h1>Manejo de Inform&#225;ticos</h1>        
    <asp:Panel ID="Informaticos" runat="server">                        
        <p>Este es el modulo de administracion de usuarios o inform&#225;ticos en el sistema, con este se puede Agregar, Modificar y Eliminar a los usuarios del sistema.</p>
        <asp:GridView ID="gvInformaticos" runat="server" AutoGenerateColumns="False" 
            AutoGenerateDeleteButton="True" AutoGenerateEditButton="True" 
            CssClass="table table-striped" GridLines="None" 
            onrowcancelingedit="gvInformaticos_RowCancelingEdit" 
            onrowcommand="Informaticos_RowCommand" 
            onrowdeleting="gvInformaticos_RowDeleting" 
            onrowediting="gvInformaticos_RowEditing" 
            onrowupdating="gvInformaticos_RowUpdating" ShowFooter="True">
            <Columns>
                <asp:TemplateField HeaderText="ID" SortExpression="ID">
                    <EditItemTemplate>
                        <asp:Label ID="lbEditID" runat="server" Text='<%# Bind("ID") %>'></asp:Label>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lbID" runat="server" Text='<%# Bind("ID") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Nombre" SortExpression="Nombre">
                    <EditItemTemplate>
                        <asp:TextBox ID="txtEditNombre" runat="server" Text='<%# Bind("Nombre") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <FooterTemplate>
                        <asp:TextBox ID="txtNombre" runat="server"></asp:TextBox>
                    </FooterTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("Nombre") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Rol" SortExpression="Rol">
                    <EditItemTemplate>
                        <asp:DropDownList ID="dropEditRol" runat="server" DataSourceID="Roles" 
                            DataTextField="NombreRol" DataValueField="NombreRol">
                        </asp:DropDownList>
                        <asp:SqlDataSource ID="Roles" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:SSTConnectionString %>" 
                            SelectCommand="SELECT [NombreRol] FROM [Rol] WHERE ([FechaBorrado] IS NULL)">
                        </asp:SqlDataSource>
                    </EditItemTemplate>
                    <FooterTemplate>
                        <asp:DropDownList ID="dropRol" runat="server" DataSourceID="Roles" 
                            DataTextField="NombreRol" DataValueField="RolID">
                        </asp:DropDownList>
                        <asp:SqlDataSource ID="Roles" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:SSTConnectionString %>" 
                            SelectCommand="SELECT [RolID], [NombreRol] FROM [Rol] WHERE ([FechaBorrado] IS NULL)">
                        </asp:SqlDataSource>
                    </FooterTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label2" runat="server" Text='<%# Bind("Rol") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Circuito" SortExpression="Circuito">
                    <EditItemTemplate>
                    
                        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:SSTConnectionString %>" 
                            SelectCommand="SELECT [CircuitoID], [NombreCircuito] FROM [Circuito] WHERE ([FechaBorrado] IS NULL)">
                        </asp:SqlDataSource>
                        <asp:ListBox ID="listEditCircuito" runat="server" DataSourceID="SqlDataSource1" 
                            DataTextField="NombreCircuito" DataValueField="CircuitoID" 
                            SelectionMode="Multiple"></asp:ListBox>
                    </EditItemTemplate>
                    <FooterTemplate>
                        <asp:DropDownList ID="dropInformaticoCircuito" runat="server" 
                            DataSourceID="CircuitoSST" DataTextField="NombreCircuito" 
                            DataValueField="NombreCircuito" Visible="False">
                        </asp:DropDownList>
                        <asp:ListBox ID="listAddCircuito" runat="server" DataSourceID="CircuitoSST" 
                            DataTextField="NombreCircuito" DataValueField="CircuitoID" 
                            SelectionMode="Multiple"></asp:ListBox>
                        <asp:SqlDataSource ID="CircuitoSST" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:SSTConnectionString %>" 
                            SelectCommand="SELECT NombreCircuito, CircuitoID FROM Circuito WHERE (FechaBorrado IS NULL)">
                        </asp:SqlDataSource>
                        <asp:SqlDataSource ID="SqlDataSource1" runat="server"></asp:SqlDataSource>
                    </FooterTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label3" runat="server" Text='<%# Bind("Circuito") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Horario" SortExpression="Horario">
                    <EditItemTemplate>
                        <asp:DropDownList ID="dropEditHorario" runat="server" DataSourceID="SST" 
                            DataTextField="Horario" DataValueField="HorarioID">
                        </asp:DropDownList>
                    </EditItemTemplate>
                    <FooterTemplate>
                        <asp:DropDownList ID="dropHorario" runat="server" DataSourceID="SST" 
                            DataTextField="Horario" DataValueField="HorarioID">
                        </asp:DropDownList>
                        &nbsp;
                        <asp:LinkButton ID="lnkbtAgregar" runat="server" CommandName="Agregar" 
                            CssClass="btn btn-primary">Agregar</asp:LinkButton>
                    </FooterTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label4" runat="server" Text='<%# Bind("Horario") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <EmptyDataTemplate>
                <asp:Label ID="EmptyLabel" runat="server"></asp:Label>
            </EmptyDataTemplate>
        </asp:GridView>
    </asp:Panel>
    
           <asp:SqlDataSource ID="SST" runat="server" 
                                ConnectionString="<%$ ConnectionStrings:SSTConnectionString %>" SelectCommand="SELECT HorarioID,
 (NombreHorario+'  '+CAST((HoraInicio/60) as VARCHAR)+':00 - '
 +CAST((HoraFin/60) as VARCHAR)+':00  Dias de trabajo: '+Dias) 'Horario'
FROM Horario
WHERE FechaBorrado IS NULL"></asp:SqlDataSource>
    </center>
</asp:Content>
